package com.lanqiao.javaparkinglot.controller;

import com.lanqiao.javaparkinglot.common.CommonResult;
import com.lanqiao.javaparkinglot.entity.Car;
import com.lanqiao.javaparkinglot.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/car")
public class CarController {

    @Autowired
    CarService carService;
    //查询
    @GetMapping("cha")
    public CommonResult findcar(){
        return CommonResult.success("停车收费表查询成功",carService.findcar());
    }
    //添加
    @PostMapping("/tianjia")
    public CommonResult addcar (@RequestBody Car car){
        carService.addcar(car);
        return CommonResult.success("车费添加成功");
    }
    //修改
    @PutMapping("xiugai")
    public CommonResult updatecar(@RequestBody Car car){
        carService.updates(car);
        return CommonResult.success("车费信息修改成功");
    }
    //删除
    @DeleteMapping("/{car_eno}")
    public CommonResult deletecar(@PathVariable ("car_eno") Long car_eno){
        carService.deletecar(car_eno);
        return CommonResult.success("删除数据成功");
    }
}
